<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		
		<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
		Remove this if you use the .htaccess -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<title>Cron Translator</title>
		<meta name="description" content="Translate cron expressions to plain English" />
		<meta name="author" content="Digao" />
		<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
		<link rel="shortcut icon" href="/favicon.ico" />
		<link rel="stylesheet" href="styles/main.css"/>
		<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
		<script src="translator.js" language="JavaScript"></script>
		<script src="jquery.js" language="JavaScript"></script>
		<script type="text/javascript">
			function AssertException(message) { this.message = message; }
			AssertException.prototype.toString = function () {
			  return 'AssertException: ' + this.message;
			}
			function assert(exp, message) {
			  if (!exp) {
			    throw new AssertException(message);
			  }
			}
			function callTranslator(exp,res){
				val='ERROR'
				try{
					val = cronParse(exp)
					assert(val===res)
					$("#result").append("<li class=\"pass\"><p>"+val+"</p></li>")
				}catch(e){
					if (val ==='ERROR') {
						$("#result").append("<li class=\"fail\"><p>Error. '"+e+"'</p></li>")
					};
					$("#result").append("<li class=\"fail\"><p>Error. Expected:'"+res+"' and was '"+val+"'</p></li>")
				}
			}
			testCases=[{inp:'0 0 12 * * ?',out:'at 00:00 on 12th of every month'},
			{inp:'0 12 * * * ?',out:'at 12:00 every day'},
			{inp:'0 0 12 1 * ?',out:'at 00:00 on 12th of January'},
			{inp:'0 0 12 2 * ?',out:'at 00:00 on 12th of February'},
			{inp:'0 0 10-20 * * ?',out:'at 00:00 from the 10th to 20th of every month'},
	         {inp:'* * 10-20 * * ?',out:'every minute from the 10th to 20th of every month'},
	         {inp:'0 * 10 2-5 * ?',out:'at 0 minutes every hour on 10th from February to May'},
	         {inp:'0 0 1,2,3 1 * ?',out:'at 00:00 on 1st,2nd,3rd of January'},
	         {inp:'0 3/6 * * * ?',out:'at 3 each 6 hours at 0 minutes every day'}
			]
			function test(){
				for (var i=0; i < testCases.length; i++) {
				  caso = testCases[i]
				  callTranslator(caso.inp,caso.out)
				};
			}
			$(document).ready(function(){
				test()
			})
		</script>
	</head>
	<body>
		<div class="central">
			<header>
				<h1>Teste</h1>
			</header>
			<hr />
			<h4>lista de resultados</h4>
			<ol id="result"></ol>
		</div>
	</body>
</html>
